import React, { Component } from 'react'
export default class App extends Component {
  fileRef = React.createRef()
  imgRef = React.createRef()
  getFile = () => {
    let file = this.fileRef.current.files[0]
    let reader = new FileReader()
    reader.readAsDataURL(file)
    const _this = this
    reader.onload = function () {
      _this.imgRef.current.src = this.result
    }
  }
  render() {
    return (
      <div>
        <input type="file" ref = { this.fileRef } onChange = { this.getFile }/>
        <img src="" ref={ this.imgRef } alt=""/>
      </div>
    )
  }
}
